<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: Widgets::Highlightable::InstanceMethods</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">Widgets::Highlightable::InstanceMethods</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/plugins/widgets/lib/widgets/highlightable_rb.html">
                vendor/plugins/widgets/lib/widgets/highlightable.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000028">highlight!</a>&nbsp;&nbsp;
      <a href="#M000029">highlighted?</a>&nbsp;&nbsp;
      <a href="#M000026">highlights</a>&nbsp;&nbsp;
      <a href="#M000027">highlights_on</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000028" class="method-detail">
        <a name="M000028"></a>

        <div class="method-heading">
          <a href="#M000028" class="method-signature">
          <span class="method-name">highlight!</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
force the tab as highlighted
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000028-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000028-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/widgets/lib/widgets/highlightable.rb, line 25</span>
25:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">highlight!</span>
26:         <span class="ruby-identifier">highlights_on</span> <span class="ruby-identifier">proc</span> { <span class="ruby-keyword kw">true</span> }
27:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000029" class="method-detail">
        <a name="M000029"></a>

        <div class="method-heading">
          <a href="#M000029" class="method-signature">
          <span class="method-name">highlighted?</span><span class="method-args">(options={})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
takes in input a Hash (usually params) or a string/Proc that evaluates to
true/false it does ignore some params like &#8216;only_path&#8217; etc.. we
have to do this in orderr to support restful routes
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000029-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/widgets/lib/widgets/highlightable.rb, line 33</span>
33:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">highlighted?</span> <span class="ruby-identifier">options</span>={}
34:         <span class="ruby-identifier">option</span> = <span class="ruby-identifier">clean_unwanted_keys</span>(<span class="ruby-identifier">options</span>)
35:         <span class="ruby-comment cmt">#puts &quot;### '#{name}'.highlighted? #{options.inspect}&quot;</span>
36:         <span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">false</span>
37:        
38:         <span class="ruby-identifier">highlights</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">highlight</span><span class="ruby-operator">|</span> <span class="ruby-comment cmt"># for every highlight(proc or hash)</span>
39:           <span class="ruby-identifier">highlighted</span> = <span class="ruby-keyword kw">true</span>
40:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">highlight</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">String</span> <span class="ruby-comment cmt"># do not highlight @TODO: should we evaluate the request URI for this?</span>
41:             <span class="ruby-identifier">highlighted</span> <span class="ruby-operator">&amp;=</span> <span class="ruby-keyword kw">false</span> 
42:           <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">highlight</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Proc</span> <span class="ruby-comment cmt"># evaluate the proc</span>
43:             <span class="ruby-identifier">h</span> = <span class="ruby-identifier">highlight</span>.<span class="ruby-identifier">call</span>
44:             <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">h</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">TrueClass</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">h</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">FalseClass</span>))
45:               <span class="ruby-identifier">highlighted</span> <span class="ruby-operator">&amp;=</span> <span class="ruby-identifier">h</span>
46:             <span class="ruby-keyword kw">else</span>
47:               <span class="ruby-identifier">raise</span> <span class="ruby-value str">'proc highlighting rules must evaluate to TrueClass or FalseClass'</span>
48:             <span class="ruby-keyword kw">end</span>
49:           <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">highlight</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Hash</span> <span class="ruby-comment cmt"># evaluate the hash</span>
50:             <span class="ruby-identifier">h</span> = <span class="ruby-identifier">clean_unwanted_keys</span>(<span class="ruby-identifier">highlight</span>)
51:             <span class="ruby-identifier">h</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>   <span class="ruby-comment cmt"># for each key</span>
52:               <span class="ruby-comment cmt"># remove first slash from &lt;tt&gt;:controller&lt;/tt&gt; key otherwise highlighted? could fail with urls such as {:controller =&gt; &quot;/base&quot;&lt;/tt&gt;</span>
53:               <span class="ruby-identifier">h_key</span> = <span class="ruby-identifier">h</span>[<span class="ruby-identifier">key</span>].<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">dup</span>
54:               <span class="ruby-identifier">h_key</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/^\//</span>,<span class="ruby-value str">&quot;&quot;</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">key</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:controller</span>          
55:               <span class="ruby-identifier">highlighted</span> <span class="ruby-operator">&amp;=</span> <span class="ruby-identifier">h_key</span><span class="ruby-operator">==</span><span class="ruby-identifier">options</span>[<span class="ruby-identifier">key</span>].<span class="ruby-identifier">to_s</span>
56:             <span class="ruby-keyword kw">end</span>
57:           <span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt"># highlighting rule not supported</span>
58:             <span class="ruby-identifier">raise</span> <span class="ruby-value str">'highlighting rules should be String, Proc or Hash'</span> 
59:           <span class="ruby-keyword kw">end</span>
60:           <span class="ruby-identifier">result</span> <span class="ruby-operator">|=</span> <span class="ruby-identifier">highlighted</span>
61:         <span class="ruby-keyword kw">end</span>
62:         <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span>
63:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000026" class="method-detail">
        <a name="M000026"></a>

        <div class="method-heading">
          <a href="#M000026" class="method-signature">
          <span class="method-name">highlights</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000026-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000026-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/widgets/lib/widgets/highlightable.rb, line 12</span>
12:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">highlights</span>
13:         <span class="ruby-ivar">@highlights</span> <span class="ruby-operator">||=</span> []
14:         <span class="ruby-ivar">@highlights</span>
15:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000027" class="method-detail">
        <a name="M000027"></a>

        <div class="method-heading">
          <a href="#M000027" class="method-signature">
          <span class="method-name">highlights_on</span><span class="method-args">(rule)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
a rule can be:
</p>
<pre>
 * a parameter hash eg: {:controller =&gt; 'main', :action =&gt; 'welcome'}
 * a string containing an URL eg: 'http://blog.seesaw.it'
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000027-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000027-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/widgets/lib/widgets/highlightable.rb, line 20</span>
20:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">highlights_on</span> <span class="ruby-identifier">rule</span>
21:         <span class="ruby-identifier">highlights</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">rule</span>
22:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>